<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Http\Controllers;

use App\Services\AdminLogService;
use Illuminate\Http\Request;

class AdminLogController extends Controller
{
    protected $adminLogService;

    public function __construct(AdminLogService $adminLogService)
    {
        $this->adminLogService = $adminLogService;
    }

    public function getList(Request $request)
    {
        $page = $request->input('page', 1);
        $pageSize = $request->input('page_size', 10);
        $search = [];
        if ($request->input('user_name')) {
            $search['user_name'] = $request->input('user_name');
        }

        if ($request->input('start_date')) {
            $search['start_date'] = $request->input('start_date');
        }

        if ($request->input('end_date')) {
            $search['end_date'] = $request->input('end_date');
        }

        $res = $this->adminLogService->getList($page, $pageSize, $search);
        return renderSuccessJson($res);
    }
}
